﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.ServiceModel.Web;
using Microsoft.Samples.WindowsAzure.ServiceManagement;

namespace WAPA.Framework
{
    /// <summary>
    /// Hold consolidated info of an API call response.
    /// </summary>
    public class ResponseInfo
    {
        public ResponseInfo()
        {
            Completed = false;
        }

        public ResponseInfo(WebOperationContext operationContext)
        {
            Completed = false;
            TrackingId = WebOperationContext.Current.IncomingResponse.Headers[Constants.OperationTrackingIdHeader];
            HttpStatusCode = WebOperationContext.Current.IncomingResponse.StatusCode;
            StatusDescription = WebOperationContext.Current.IncomingResponse.StatusDescription;
            CommunicationExceptionMessage = null;
            ErrorMessage = null;
            ActionDescription = ManagementContext.CurrentActionDescription;
            
        }

        public bool Completed { get; set; }
        public string Status { get; set; }
        public string TrackingId {get;set;}
        public HttpStatusCode? HttpStatusCode {get;set;}
        public string StatusDescription { get; set; }
        public string CommunicationExceptionMessage { get; set; }
        public string ErrorMessage { get; set; }
        public string ActionDescription { get; set; }
    }
}
